Freeware assember ASxx.EXE Ver 1.03. 0001 f800 ORG 0F800H 0002 ; 0003 0004 DRVNO EQU 04H ;set to appropriate AdamNet node 0004 ; 0005 0000 P1DDR EQU 00H ;port 1 data direction register 0006 0001 P2DDR EQU 01H ;port 2 data direction register 0007 0002 P1DATA EQU 02H ;port 1 data register 0008 0003 P2DATA EQU 03H ;port 2 data register 0009 0005 P4DDR EQU 05H ;port 4 data direction register 0010 0008 TCSR EQU 08H ;timer control and status register 0011 0009 COUNTER EQU 09H ;counter register 0012 000b OUTCMP EQU 0BH ;output compare register 0013 0010 RMCR EQU 10H ;SCI rate and mode control register 0014 0011 SCICSR EQU 11H ;SCI Tx/Rx control and status register 0015 0012 SCIRXD EQU 12H ;SCI Rx data register 0016 0013 SCITXD EQU 13H ;SCI Tx data register 0017 0014 RAMCR EQU 14H ;RAM control register 0018 0080 CURMSG EQU 80H ;command message buffer (instructions for send/rcv) 0019 0085 LSTMSG EQU 85H ;last command buffer 0020 008a STRLEN EQU 8AH ;message length 0021 008c BLKLOC EQU 8CH ;where in memory to get/save message 0022 008e CHKSUM EQU 8EH ;calculated checksum 0023 008f MSTAT EQU 8FH ;status message buffer 0024 0093 CSTAT EQU 93H ;combined status 0025 0094 PSTAT EQU 94H ;primary status 0026 0095 SSTAT EQU 95H ;secondary status 0027 0096 L0096 EQU 96H 0028 0098 DEVNUM EQU 98H ;device node ID 0029 0099 CMDSTG EQU 99H ;command stage for multi-byte commands 0030 009e DATREQ EQU 9EH ;data requested flag 0031 009f RDWRT EQU 9FH ;read(=0BH)/write(=0CH) flag 0032 00a0 INTHAN EQU 0A0H ;address for interrupt handler 0033 00a2 DMADDR EQU 0A2H ;address for DMA with FDC 0034 00a4 STFDC EQU 0A4H ;FDC status 0035 00a5 REQTRK EQU 0A5H ;requested track 0036 00a6 REQSEC EQU 0A6H ;requested sector 0037 00a7 CURSEC EQU 0A7H ;current sector 0038 00a8 CURTRK EQU 0A8H ;current track 0039 00a9 SECCNT EQU 0A9H ;number of sectors to read 0040 00aa RETRY EQU 0AAH ;number of retries 0041 00ab DRVUSE EQU 0ABH ;has the drive been used? 0042 00ac MOTON EQU 0ACH ;is the motor on 0043 00e9 FMTTRK EQU 0E9H ;track being formatted 0044 00ea FMTSEC EQU 0EAH ;sector being formatted 0045 00eb FMTRTRY EQU 0EBH ;retries while formatting 0046 00ec SIDE EQU 0ECH ;side being formatted 0047 ; 0048 0400 BLKWRT EQU 400H ;write to external memory 0049 0800 FDCSTAT EQU 800H ;FDC status register 0050 1400 BLKRD EQU 1400H ;read from external memory 0051 1800 FDCCMD EQU 1800H ;FDC command register 0052 3800 FDCTRK EQU 3800H ;FDC track register 0053 5800 FDCSEC EQU 5800H ;FDC sector register 0054 6c00 RDMA0 EQU 6C00H ;DMA read from FDC to 0 to 1FFH of ext. mem. 0055 6e00 RDMA1 EQU 6E00H ;DMA read from FDC to 200H to 3FFH of ext. mem. 0056 7800 FDCDAT EQU 7800H ;FDC data register 0057 7c00 WDMA0 EQU 7C00H ;DMA write to FDC from 0 to 1FFH of ext. mem. 0058 7e00 WDMA1 EQU 7E00H ;DMA write to FDC from 200H to 3FFH of ext. mem. 0059 ; 0060 ;AdamNet Messages where N = Node ID 0061 ; 0N - reset node 0062 ; 1N - request status 0063 ; 3N - clear 0064 ; 4N - receive 0065 ; 6N - send 0066 ;0DN - ready 0067 ; 0068 ; The disk drive code comprises two separate devices, the net handler 0069 ; and the disk handler. The net handler is only triggered when the 6803 0070 ; receives a byte over AdamNet. It interprets the AdamNet command, acts 0071 ; on the command (including sending and receiving blocks of data over the 0072 ; Net) and sets the appropriate flags and data blocks in memory. The 0073 ; disk handler is normally in control of the drive. It initializes the 0074 ; various flags and hardware and then loops, monitoring the data request 0075 ; flag. When it finds a data request, it reads or writes to the disk 0076 ; drive, depending upon the read/write flag. If the disk handler gets 0077 ; a request to write to block FACEH, it does a format. 0078 ; 0079 ;AdamNet procedure to write to disk: 0080 ; 1) Master node uses send command to send block specifications to disk drive. 0081 ; Block spec. is 5 bytes, 4 bytes block number (LSB ... MSB) and one byte 0082 ; device spec (0 = primary device, NZ = secondary device). The net 0083 ; handler puts all blocks less than 400H in message buffer. Blocks of 0084 ; 400H go in external memory. 0085 ; 2) Master node uses send command to send data block to disk. 0086 ; 3) Net handler sets data request and write flags and returns to disk 0087 ; handler. 0088 ; 4) Disk handler sees flags, reads the block specification and writes 0089 ; external memory to disk. 0090 ;AdamNet procedure to read from disk: 0091 ; 1) Master node uses send command to send block specifications to disk drive. 0092 ; 2) Master node uses receive command to tell disk drive to send data block. 0093 ; 3) Net handler sets data request and read flags and returns to disk 0094 ; handler. 0095 ; 4) Disk handler sees flags, reads the block specification and reads data 0096 ; from disk to external memory. 0097 ; 5) Meanwhile master node queries drive with RDY command. 0098 ; 6) Drive ACKs ready when disk handler has comleted task. 0099 ; 7) Master node then uses CLEAR command to tell net handler to send data. 0100 ; 8) Net handler now sends data in external memory 0101 ; 0102 f800 17 TBA ;unused 0103 SCIINT: 0104 f801 7d 00 9e TST DATREQ ;is there an active data request 0105 f804 26 26 BNE SCINT3 ;if none, finish up, ignoring Net 0106 f806 bd f9 f3 JSR RDSCI ;read byte from SCI 0107 f809 25 2b BCS SCINT4 ;jump if good read (and good net address) 0108 f80b 28 1f BVC SCINT3 ;if address bad, finish up, ignoring Net 0109 ;must be bad read, so NACK it 0110 f80d 86 02 LDAA #$2 ;enable Tx interrupt 0111 f80f 97 11 STAA SCICSR 0112 SCINT1: 0113 f811 ce 00 0e LDX #$0E ;set wait count 0114 f814 86 08 LDAA #$8 ;get ready to test bit 3 0115 SCINT2: 0116 f816 95 03 BITA P2DATA ;is bit 3 of port 2 data set by SCI 0117 f818 27 f7 BEQ SCINT1 ;no, loop until it's set 0118 f81a 09 DEX ;make sure it stays set long enough 0119 f81b 26 f9 BNE SCINT2 ;by looping until IX = 0 0120 f81d 86 1b LDAA #$1B ;enable Rx, RxI, Wakeup 0121 f81f 97 11 STAA SCICSR 0122 f821 7d 00 99 TST CMDSTG ;are we in the middle of a command 0123 f824 27 06 BEQ SCINT3 ;no, just reset SCI 0124 f826 4f CLRA ;clear command stage flag 0125 f827 97 99 STAA CMDSTG 0126 f829 7e f8 92 JMP NACK ;send NACK 0127 SCINT3: 0128 f82c c6 1b LDAB #$1B ;enable Rx, RxI, Wakeup 0129 f82e d7 11 STAB SCICSR 0130 f830 4f CLRA ;clear command stage flag 0131 f831 97 99 STAA CMDSTG 0132 f833 7e f9 d2 JMP SCIEND ;reset SCI 0133 SCINT4: 0134 f836 d6 99 LDAB CMDSTG ;get the command stage flag in B 0135 f838 58 ASLB ;multiply by 2 0136 f839 ce f8 41 LDX #TBL1 ;point to command jump table 0137 f83c 3a ABX ;add offset in B 0138 f83d ee 00 LDX $0,X ;get address from table 0139 JMPIX: 0140 f83f 6e 00 JMP $0,X ;jump to address 0141 TBL1: 0142 f841 f8 4d DW STAGE0 0143 f843 f9 28 DW STAGE1 0144 f845 f9 31 DW STAGE2 0145 f847 f9 56 DW STAGE3 0146 f849 f9 5d DW STAGE4 0147 f84b f9 77 DW STAGE5 0148 STAGE0: 0149 f84d 84 f0 ANDA #$0F0 ;mask off lower nibble 0150 f84f 81 00 CMPA #$0 ;is it NetReset 0151 f851 26 07 BNE NOTRST ;no, check other commands 0152 f853 0d SEC ;set carry 0153 f854 bd fa 54 JSR SETREQ 0154 f857 7e f9 d2 JMP SCIEND ;reset SCI 0155 NOTRST: 0156 f85a 81 10 CMPA #$10 ;is it status request? 0157 f85c 27 5c BEQ STATUS ;yes, jump 0158 f85e 81 30 CMPA #$30 ;is it clear 0159 f860 26 03 BNE NOTCLR ;no, jump 0160 f862 7e f8 e6 JMP CLEAR 0161 NOTCLR: 0162 f865 81 40 CMPA #$40 ;is it Rx 0163 f867 26 17 BNE NOTRX ;no, jump 0164 f869 ce 00 05 LDX #$5 ;counter to test 5 bytes 0165 RX1: 0166 f86c a6 7f LDAA $7F,X ;compare location 7F+X 0167 f86e a1 84 CMPA $84,X ;to location 84+X 0168 f870 26 05 BNE RX2 ;jump if different 0169 f872 09 DEX ;check counter 0170 f873 26 f7 BNE RX1 ;loop if more bytes to check 0171 f875 20 2f BRA ACK ;all the same to send ACK 0172 RX2: 0173 f877 86 0b LDAA #$0B 0174 f879 0c CLC 0175 f87a bd fa 54 JSR SETREQ 0176 f87d 7e f9 d2 JMP SCIEND 0177 NOTRX: 0178 f880 81 60 CMPA #$60 ;is it send 0179 f882 26 07 BNE NOTSND ;no, jump 0180 f884 86 01 LDAA #$1 ;now stage 0 0181 f886 97 99 STAA CMDSTG ;so set it 0182 f888 7e f9 d2 JMP SCIEND ;reset SCi 0183 NOTSND: 0184 f88b 81 d0 CMPA #$0D0 ;is it RDY 0185 f88d 27 17 BEQ ACK ;yes, send ACK 0186 f88f 7e f9 d2 JMP SCIEND ;else reset SCI (ignore command) 0187 NACK: 0188 f892 86 c0 LDAA #$0C0 ;NACK in upper nibble of A 0189 f894 9a 98 ORAA DEVNUM ;node ID in lower nibble of A 0190 f896 bd fa 11 JSR TXBYTE ;send it 0191 f899 25 08 BCS NACK1 ;if bad send 0192 f89b bd fa 29 JSR RXBYTE ;get response 0193 f89e 25 03 BCS NACK1 ;if bad receive 0194 f8a0 7e f9 d2 JMP SCIEND ;reset SCI 0195 NACK1: 0196 f8a3 7e f9 e2 JMP SCIND1 ;return from interrupt 0197 ACK: 0198 f8a6 86 90 LDAA #$90 ;ACK in upper nibble of A 0199 f8a8 9a 98 ORAA DEVNUM ;node ID in lower nibble 0200 f8aa bd fa 11 JSR TXBYTE ;send it 0201 f8ad 25 08 BCS ACK1 ;if bad send 0202 f8af bd fa 29 JSR RXBYTE ;get response 0203 f8b2 25 03 BCS ACK1 ;if bad receive 0204 f8b4 7e f9 d2 JMP SCIEND ;reset SCI 0205 ACK1: 0206 f8b7 7e f9 e2 JMP SCIND1 ;return from interrupt 0207 STATUS: 0208 f8ba fc f9 ee LDD TBL2 ;load double accumulator with 8000H 0209 ;(status + MSB of msg len) 0210 f8bd 9a 98 ORAA DEVNUM ;put device number in lower nibble of A (=80) 0211 f8bf dd 8f STD MSTAT ;save in buffer for status message 0212 f8c1 fc f9 f0 LDD TBL3 ;load double accumulator with 401H 0213 f8c4 dd 91 STD MSTAT+2 ;put in 91 and 92 0214 f8c6 bd f9 e3 JSR GETSTAT ;put double stat in 93 0215 f8c9 ce 00 8f LDX #MSTAT ;point to string to send 0216 f8cc cc 00 05 LDD #$5 ;load double accumulator with string length 0217 f8cf dd 8a STD STRLEN ;save string length 0218 f8d1 86 80 LDAA #$80 ;initialize checksum 0219 f8d3 9a 98 ORAA DEVNUM 0220 f8d5 97 8e STAA CHKSUM 0221 f8d7 bd f9 b2 JSR TXSTR ;send response 0222 f8da 25 07 BCS STAT1 ;if error 0223 f8dc 86 01 LDAA #$1 0224 f8de 97 96 STAA L0096 ;put 1 if ???? flag - not used anywhere else 0225 f8e0 7e f9 d2 JMP SCIEND ;reset SCI 0226 STAT1: 0227 f8e3 7e f9 e2 JMP SCIND1 ;jump to RTI 0228 CLEAR: 0229 f8e6 7d 00 84 TST CURMSG+4 ;was the last command for primary device 0230 f8e9 27 04 BEQ CLR1 ;yes, skip next 0231 f8eb 96 95 LDAA SSTAT ;so load secondary device status 0232 f8ed 20 02 BRA CLR2 ;skip next 0233 CLR1: 0234 f8ef 96 94 LDAA PSTAT ;get primary device status 0235 CLR2: 0236 f8f1 81 03 CMPA #$3 ;test status 0237 f8f3 24 0a BCC CLR3 ;if 3 or greater, jump 0238 f8f5 ce 14 00 LDX #BLKRD ;get ready to read external memory 0239 f8f8 cc 04 00 LDD #$0400 ;400H to send 0240 f8fb dd 8a STD STRLEN ;so set message length 0241 f8fd 20 0b BRA CLR4 ;skip next 0242 CLR3: 0243 f8ff bd f9 e3 JSR GETSTAT ;put combined status message in CSTAT 0244 f902 ce 00 93 LDX #CSTAT ;point to CSTAT 0245 f905 cc 00 01 LDD #$1 ;message length = 1 0246 f908 dd 8a STD STRLEN 0247 CLR4: 0248 f90a bd f9 98 JSR SNDMSG ;send message (Block or error) 0249 f90d 25 16 BCS CLR8 ;if error 0250 f90f 7d 00 84 TST CURMSG+4 ;was last for primary device 0251 f912 27 04 BEQ CLR5 ;yes, skip next 0252 f914 96 95 LDAA SSTAT ;get secondary status 0253 f916 20 02 BRA CLR6 ;skip next 0254 CLR5: 0255 f918 96 94 LDAA PSTAT ;get primary status 0256 CLR6: 0257 f91a 81 01 CMPA #$1 ;test status 0258 f91c 26 04 BNE CLR7 ;if not 1, jump 0259 f91e 86 ff LDAA #$0FF ;set external memory contents bad 0260 f920 97 89 STAA LSTMSG+4 0261 CLR7: 0262 f922 7e f9 d2 JMP SCIEND ;exit 0263 CLR8: 0264 f925 7e f9 e2 JMP SCIND1 ;do simple RTI 0265 STAGE1: 0266 ;A = MSB of message length 0267 f928 97 8a STAA STRLEN ;save MSB of message length 0268 f92a 86 02 LDAA #$2 ;activate stage 2 0269 f92c 97 99 STAA CMDSTG 0270 f92e 7e f9 d2 JMP SCIEND ;reset SCI 0271 STAGE2: 0272 ;A = LSB of message length 0273 f931 97 8b STAA STRLEN+1 ;save LSB of message length 0274 f933 81 05 CMPA #$5 ;is it 5? 0275 f935 26 04 BNE STAG21 ;no, it must be 400H 0276 f937 96 8a LDAA STRLEN ;get MSB of message length 0277 f939 27 0c BEQ STAG22 ;if it's 0, ie 0005, jump 0278 STAG21: 0279 f93b 86 03 LDAA #$3 ;activate stage 3 0280 f93d 97 99 STAA CMDSTG 0281 f93f cc 04 00 LDD #BLKWRT ;block to go at 400H 0282 f942 dd 8c STD BLKLOC 0283 f944 7e f9 d2 JMP SCIEND ;reset SCI 0284 STAG22: 0285 f947 86 04 LDAA #$4 ;activate stage 4 0286 f949 97 99 STAA CMDSTG 0287 f94b cc 00 80 LDD #$80 ;block to go at 80H 0288 f94e dd 8c STD BLKLOC 0289 f950 7f 00 8e CLR CHKSUM ;clear the checksum 0290 f953 7e f9 d2 JMP SCIEND ;reset SCI 0291 STAGE3: 0292 ;A = first byte of message 0293 f956 c6 04 LDAB #$4 ;activate stage 4 0294 f958 d7 99 STAB CMDSTG 0295 f95a 7f 00 8e CLR CHKSUM ;clear checksum 0296 STAGE4: 0297 ;A = message byte 0298 f95d de 8c LDX BLKLOC ;get memory location to save message 0299 f95f a7 00 STAA $0,X ;save there 0300 f961 08 INX ;increment pointer 0301 f962 df 8c STX BLKLOC ;save it 0302 f964 98 8e EORA CHKSUM ;calculate checksum 0303 f966 97 8e STAA CHKSUM ;save it 0304 f968 dc 8a LDD STRLEN ;get message length 0305 f96a 83 00 01 SUBD #$1 ;decrement it 0306 f96d dd 8a STD STRLEN ;save it 0307 f96f 26 61 BNE SCIEND ;reset SCI if not done 0308 f971 86 05 LDAA #$5 ;else activate stage 5 0309 f973 97 99 STAA CMDSTG 0310 f975 20 5b BRA SCIEND ;and reset SCI 0311 STAGE5: 0312 ;A = message checksum 0313 f977 c6 00 LDAB #$0 ;reset commmand stage to 0 0314 f979 d7 99 STAB CMDSTG 0315 f97b 91 8e CMPA CHKSUM ;check against calculated checksum 0316 f97d 27 07 BEQ STAG51 ;if they're the same jump 0317 f97f 86 02 LDAA #$2 ;else set primary status to 2 0318 f981 97 94 STAA PSTAT 0319 f983 7e f8 92 JMP NACK ;and send NACK 0320 STAG51: 0321 f986 de 8c LDX BLKLOC ;check if loaded at 80H or 400H 0322 f988 8c 01 00 CPX #$0100 0323 f98b 25 08 BCS STAG52 ;carry set if 80H, so just send ACK 0324 f98d 86 0c LDAA #$0C ;set data write 0325 f98f 97 9f STAA RDWRT 0326 f991 86 aa LDAA #$0AA ;data request flag 0327 f993 97 9e STAA DATREQ 0328 STAG52: 0329 f995 7e f8 a6 JMP ACK ;send ACK 0330 SNDMSG: 0331 f998 86 b0 LDAA #$0B0 ;Minor node send 0332 f99a 9a 98 ORAA DEVNUM ;or in Node ID 0333 f99c bd fa 11 JSR TXBYTE ;send it 0334 f99f 25 30 BCS TXSTR1 ;if bad send 0335 f9a1 96 8a LDAA STRLEN ;get message length MSB 0336 f9a3 bd fa 11 JSR TXBYTE ;send it 0337 f9a6 25 29 BCS TXSTR1 ;if bad send 0338 f9a8 96 8b LDAA STRLEN+1 ;get message length LSB 0339 f9aa bd fa 11 JSR TXBYTE ;send it 0340 f9ad 25 22 BCS TXSTR1 ;if bad send 0341 f9af 7f 00 8e CLR CHKSUM ;clear checksum and fall through to send message 0342 TXSTR: 0343 f9b2 a6 00 LDAA $0,X ;get byte pointed to by IX 0344 f9b4 bd fa 11 JSR TXBYTE ;send it 0345 f9b7 25 18 BCS TXSTR1 ;jump if error 0346 f9b9 98 8e EORA CHKSUM ;generate checksum 0347 f9bb 97 8e STAA CHKSUM ;save it 0348 f9bd 08 INX ;increment pointer 0349 f9be dc 8a LDD STRLEN ;load DA with string length 0350 f9c0 83 00 01 SUBD #$1 ;decrement it 0351 f9c3 dd 8a STD STRLEN ;save string length 0352 f9c5 26 eb BNE TXSTR ;send more if leength > 0 0353 f9c7 96 8e LDAA CHKSUM ;get checksum 0354 f9c9 bd fa 11 JSR TXBYTE ;send it 0355 f9cc 25 03 BCS TXSTR1 ;if error 0356 f9ce bd fa 29 JSR RXBYTE ;get response 0357 TXSTR1: 0358 f9d1 39 RTS 0359 SCIEND: 0360 f9d2 7d 00 9e TST DATREQ ;test SCI status flag 0361 f9d5 27 0b BEQ SCIND1 ;if it's 0 exit, SCI routine 0362 f9d7 86 0a LDAA #$0A ;enable Rx & Tx, but disable interrupts 0363 f9d9 97 11 STAA SCICSR 0364 f9db 96 11 LDAA SCICSR ;read status to reset 0365 f9dd 96 12 LDAA SCIRXD ;read receive to reset 0366 f9df bd fa 29 JSR RXBYTE ;read byte from Net 0367 SCIND1: 0368 f9e2 3b RTI ;return from SCI interrupt 0369 GETSTAT: 0370 f9e3 96 95 LDAA SSTAT ;get contents of 95 in A 0371 f9e5 48 ASLA ;put in upper nibble 0372 f9e6 48 ASLA 0373 f9e7 48 ASLA 0374 f9e8 48 ASLA 0375 f9e9 9a 94 ORAA PSTAT ;put 94 in lower nibble 0376 f9eb 97 93 STAA CSTAT ;save in 93 0377 f9ed 39 RTS 0378 TBL2: 0379 f9ee 80 00 DW $8000 0380 TBL3: 0381 f9f0 04 01 DW $401 0382 f9f2 00 DB $0 0383 RDSCI: 0384 f9f3 0d SEC ;set carry flag 0385 f9f4 d6 11 LDAB SCICSR ;get SCI status in B 0386 f9f6 96 12 LDAA SCIRXD ;read SCI data 0387 f9f8 c4 40 ANDB #$40 ;check for read errors, carry not affected 0388 f9fa 27 03 BEQ RDSCI1 ;branch if no error 0389 f9fc 0c CLC ;clear the carry 0390 f9fd 0b SEV ;set overflow 0391 f9fe 39 RTS 0392 RDSCI1: 0393 f9ff d6 99 LDAB CMDSTG ;check if in middle of a command 0394 fa01 26 0c BNE RDSCI3 ;branch if so 0395 fa03 16 TAB ;transfer Node ID to B 0396 fa04 84 0f ANDA #$0F ;look at lower nibble of ID 0397 fa06 91 98 CMPA DEVNUM ;is it us 0398 fa08 26 04 BNE RDSCI2 ;jump if not 0399 fa0a 17 TBA ;put byte back in A 0400 fa0b 0d SEC ;set the carry 0401 fa0c 20 01 BRA RDSCI3 ;clear next 0402 RDSCI2: 0403 fa0e 0c CLC ;clear carry 0404 RDSCI3: 0405 fa0f 0a CLV ;clear overflow 0406 fa10 39 RTS 0407 TXBYTE: 0408 fa11 3c PSHX ;save IX 0409 fa12 ce 00 16 LDX #$16 ;store count for timeout 0410 TXBYT1: 0411 fa15 09 DEX ;decrement count 0412 fa16 27 0b BEQ TXBYT2 ;timeout if count exhausted 0413 fa18 d6 11 LDAB SCICSR ;get SCI status 0414 fa1a c4 20 ANDB #$20 ;is Tx register full 0415 fa1c 27 f7 BEQ TXBYT1 ;wait if it is 0416 fa1e 97 13 STAA SCITXD ;put byte in Tx register (send it) 0417 fa20 0c CLC ;clear the carry 0418 fa21 20 04 BRA TXBYT3 ;exit 0419 TXBYT2: 0420 fa23 bd fa 47 JSR SCIRES ;reset SCI 0421 fa26 0d SEC ;set the carry 0422 TXBYT3: 0423 fa27 38 PULX ;restore IX 0424 fa28 39 RTS 0425 RXBYTE: 0426 fa29 3c PSHX ;save IX 0427 fa2a ce 00 22 LDX #$22 ;count for timeout 0428 RXBYT1: 0429 fa2d 09 DEX ;decrement count 0430 fa2e 27 13 BEQ RXBYT3 ;timeout if count exhausted 0431 fa30 d6 11 LDAB SCICSR ;get SCI status 0432 fa32 c4 20 ANDB #$20 ;check if last byte transmitted yet 0433 fa34 27 f7 BEQ RXBYT1 ;wait until it is 0434 fa36 d6 12 LDAB SCIRXD ;read Rx data 0435 RXBYT2: 0436 fa38 09 DEX ;decrement counter 0437 fa39 27 08 BEQ RXBYT3 ;if timed out 0438 fa3b d6 11 LDAB SCICSR ;read SCI status 0439 fa3d 2a f9 BPL RXBYT2 ;loop if bit 7 is not set 0440 fa3f d6 12 LDAB SCIRXD ;read byte 0441 fa41 38 PULX ;restore IX 0442 fa42 39 RTS 0443 RXBYT3: 0444 fa43 8d 02 BSR SCIRES ;reset SCI 0445 fa45 38 PULX ;restore IX 0446 fa46 39 RTS 0447 SCIRES: 0448 fa47 d6 11 LDAB SCICSR ;read SCI status 0449 fa49 d6 12 LDAB SCIRXD ;clear any received data 0450 fa4b c6 1b LDAB #$1B ;enable Rx, Tx, Wakeup 0451 fa4d d7 11 STAB SCICSR 0452 fa4f c6 00 LDAB #$0 ;reset command stage to 0 0453 fa51 d7 99 STAB CMDSTG 0454 fa53 39 RTS 0455 SETREQ: 0456 fa54 24 06 BCC SETRQ1 ;if carry clear, ie if not called by reset command 0457 fa56 86 ff LDAA #$0FF ;put FF in DATREQ 0458 fa58 97 9e STAA DATREQ 0459 fa5a 20 0a BRA SETRQ2 ;return 0460 SETRQ1: 0461 fa5c 97 9f STAA RDWRT ;put's 0BH in RDWRT to force a read 0462 fa5e 86 aa LDAA #$0AA ;put AA in DATREQ 0463 fa60 97 9e STAA DATREQ 0464 fa62 86 0b LDAA #$0B ;disable receive interrupt 0465 fa64 97 11 STAA SCICSR 0466 SETRQ2: 0467 fa66 39 RTS 0468 RESET: 0469 fa67 0f SEI ;disable interrupts 0470 fa68 8e 00 e8 LDS #$0E8 ;set stack pointer to E8 0471 fa6b 86 7a LDAA #$7A ;set port 1 data direction to 01111000 0472 fa6d 97 00 STAA P1DDR 0473 fa6f 86 ff LDAA #$0FF ;set port 4 data direction to 11111111 0474 fa71 97 05 STAA P4DDR 0475 fa73 86 15 LDAA #$15 ;set port 2 data direction to 00010101 0476 fa75 97 01 STAA P2DDR 0477 fa77 86 04 LDAA #$4 ;set SCI rate & mode 62.5 kbaud, NRZ, internal 0478 ;clock, post2 bit 2 not used 0479 fa79 97 10 STAA RMCR 0480 fa7b 86 1b LDAA #$1B ;enable Rx, Tx, Wakeup 0481 fa7d 97 11 STAA SCICSR 0482 fa7f 86 ff LDAA #$0FF ;enable internal ram 0483 fa81 97 14 STAA RAMCR 0484 fa83 86 10 LDAA #$10 ;enable precomp; double density, side 0, 0485 ;select drive 1, motor off 0486 fa85 97 02 STAA P1DATA 0487 fa87 ce 00 ff LDX #$0FF ;start clearing memory at 0FFH 0488 RESET1: 0489 fa8a 6f 00 CLR $0,X ;reset memory 0490 fa8c 09 DEX ;decrement pointer 0491 fa8d 8c 00 80 CPX #$80 ;is it 80H 0492 fa90 24 f8 BCC RESET1 ;no, loop 0493 fa92 7a 00 89 DEC LSTMSG+4 ;set lstmsg+4 to 0FFH 0494 fa95 7c 00 ab INC DRVUSE ;set DRVUSE to 1 0495 fa98 96 02 LDAA P1DATA ;read port 1 0496 fa9a 84 80 ANDA #$80 ;is switch on back set to drive ID 2 0497 fa9c 0c CLC ;clear carry 0498 fa9d 49 ROLA ;move bit 7 to bit 1 0499 fa9e 49 ROLA 0500 ; 0501 fa9f 8a 04 ORAA #DRVNO ;or in base drive ID 0502 ; 0503 faa1 97 98 STAA DEVNUM ;save it 0504 faa3 ce fa ab LDX #MAIN ;MAIN is to be executed by interrupt 0505 faa6 df a0 STX INTHAN ;save it 0506 faa8 7e fc 83 JMP DSKRES 0507 MAIN: 0508 faab ce 08 00 LDX #FDCSTAT ;read FDC status register 0509 faae e6 00 LDAB $0,X 0510 fab0 ce fa ab LDX #MAIN ;set up interrupt handler 0511 fab3 df a0 STX INTHAN 0512 fab5 96 ac LDAA MOTON ;is MOTON 0 yet? 0513 fab7 27 1a BEQ MAIN1 ;branch if so 0514 fab9 86 40 LDAA #$40 ;is the output compare flag set 0515 fabb 95 08 BITA TCSR 0516 fabd 27 14 BEQ MAIN1 ;branch if not 0517 fabf 96 08 LDAA TCSR ;read TCSR 0518 fac1 dc 09 LDD COUNTER ;set output compare to counter+3E80H 0519 fac3 c3 3e 80 ADDD #$3E80 0520 fac6 dd 0b STD OUTCMP 0521 fac8 7a 00 ac DEC MOTON ;decrement MOTON 0522 facb 26 06 BNE MAIN1 ;non-zero, skip next 0523 facd 96 02 LDAA P1DATA 0524 facf 84 9f ANDA #$9F ;turn motor off, select drive 1 0525 fad1 97 02 STAA P1DATA 0526 MAIN1: 0527 fad3 96 9e LDAA DATREQ ;is there a data request 0528 fad5 26 40 BNE MAIN4 ;yes, skip next 0529 fad7 c6 04 LDAB #$4 ;set secondary status to missing drive 0530 fad9 d7 95 STAB SSTAT 0531 fadb d6 02 LDAB P1DATA ;test if disk in place 0532 fadd c5 01 BITB #$1 0533 fadf 27 14 BEQ MAIN2 ;jump if it is 0534 fae1 86 03 LDAA #$3 ;set primary status to missing media 0535 fae3 97 94 STAA PSTAT 0536 fae5 86 ff LDAA #$0FF ;invalidate last command 0537 fae7 97 89 STAA LSTMSG+4 0538 fae9 86 01 LDAA #$1 0539 faeb 97 ab STAA DRVUSE 0540 faed 96 02 LDAA P1DATA ;motor off, select drive 1 0541 faef 84 9f ANDA #$9F 0542 faf1 97 02 STAA P1DATA 0543 faf3 20 1e BRA MAIN3 0544 MAIN2: 0545 faf5 4f CLRA ;put 0 in A 0546 faf6 d6 94 LDAB PSTAT ;primary status in B 0547 faf8 c1 03 CMPB #$3 ;missing media or less 0548 fafa 25 17 BCS MAIN3 ;yes, skip next 0549 fafc c1 05 CMPB #$5 ;write protected 0550 fafe 27 13 BEQ MAIN3 ;yes,skip next 0551 fb00 36 PSHA ;save A and B 0552 fb01 37 PSHB 0553 fb02 96 02 LDAA P1DATA 0554 fb04 8a 50 ORAA #$50 ;select side 0, turn motor on 0555 fb06 97 02 STAA P1DATA 0556 fb08 bd fe 01 JSR RCOUNT ;restore counter 0557 fb0b 33 PULB ;restore A & B 0558 fb0c 32 PULA 0559 fb0d c1 05 CMPB #$5 ;write protected? 0560 fb0f 27 02 BEQ MAIN3 ;yes, skip next 0561 fb11 97 94 STAA PSTAT ;save new primary status 0562 MAIN3: 0563 fb13 96 9e LDAA DATREQ ;is there a data request 0564 fb15 27 94 BEQ MAIN ;no, return to start of main loop 0565 MAIN4: 0566 fb17 81 ff CMPA #$0FF ;is it reset drive request 0567 fb19 27 6c BEQ RESDRV ;yes, skip next 0568 fb1b d6 84 LDAB CURMSG+4 ;is the primary device requested? 0569 fb1d 27 05 BEQ DODATA ;yes, skip next 0570 fb1f 7f 00 9e CLR DATREQ ;clear data request 0571 fb22 20 87 BRA MAIN ;loop some more 0572 DODATA: 0573 fb24 0f SEI ;disable interrupts 0574 fb25 96 02 LDAA P1DATA ;test if disk in place 0575 fb27 85 01 BITA #$1 0576 fb29 27 03 BEQ DODAT1 ;yes, skip nest 0577 fb2b 7e fc 83 JMP DSKRES ;reset disk system 0578 DODAT1: 0579 fb2e bd fd de JSR SELDRV ;select the drive 0580 fb31 ce 00 b4 LDX #$0B4 ;wait count 0581 DODAT2: 0582 fb34 09 DEX 0583 fb35 26 fd BNE DODAT2 0584 fb37 7d 00 ab TST DRVUSE ;is this the first time the drive is used? 0585 fb3a 27 06 BEQ DODAT3 ;no, skip next 0586 fb3c bd fc bd JSR HOMDSK ;home the disk 0587 fb3f 7f 00 ab CLR DRVUSE ;set used flag 0588 DODAT3: 0589 fb42 96 9f LDAA RDWRT ;test read/write flag 0590 fb44 81 0c CMPA #$0C ;is it write? 0591 fb46 26 2a BNE RDWRIT ;no, skip next 0592 fb48 de 80 LDX CURMSG ;get requested block 0593 fb4a 8c 53 ca CPX #$53CA ;is it CA53 0594 fb4d 26 02 BNE CHKFMT ;no, check if it is format 0595 fb4f 20 1b BRA NOTFMT ;yes, skip next 0596 CHKFMT: 0597 fb51 8c ce fa CPX #$0CEFA ;is it format = FACEH 0598 fb54 26 1c BNE RDWRIT ;no, skip next 0599 fb56 bd fe 4f JSR FORMAT ;do the format 0600 fb59 7f 00 a5 CLR REQTRK ;set requested track to 0 0601 fb5c 86 ff LDAA #$0FF ;set all message bytes to 0FFH 0602 fb5e c6 ff LDAB #$0FF 0603 fb60 dd 85 STD LSTMSG 0604 fb62 dd 87 STD LSTMSG+2 0605 fb64 97 89 STAA LSTMSG+4 0606 fb66 dd 80 STD CURMSG 0607 fb68 dd 80 STD CURMSG ;should be +2 ####### 0608 fb6a 97 80 STAA CURMSG ; and +4 0609 NOTFMT: 0610 fb6c 7f 00 9e CLR DATREQ ;clear data request flag 0611 fb6f 7e fc 5d JMP OKRDWR ;finish up with no error 0612 RDWRIT: 0613 fb72 bd fc 91 JSR CLCTRK ;calculate track and sector 0614 fb75 24 03 BCC RDWRT1 ;if good, jump 0615 fb77 7e fc 74 JMP MISBLK ;finish up with error 0616 RDWRT1: 0617 fb7a 96 9f LDAA RDWRT ;get read/write flag 0618 fb7c 81 0b CMPA #$0B ;is it read 0619 fb7e 27 10 BEQ RDBLK ;yes, do read 0620 fb80 81 0c CMPA #$0C ;is it write 0621 fb82 27 7c BEQ WRTBLK ;yes, do write 0622 fb84 7e fc 5d JMP OKRDWR ;else finish up no error 0623 RESDRV: 0624 fb87 bd fd de JSR SELDRV ;turn drive on and select it 0625 fb8a bd fc bd JSR HOMDSK ;home the disk 0626 fb8d 7e fa 67 JMP RESET ;reset entire drive system 0627 RDBLK: 0628 fb90 96 02 LDAA P1DATA ;is disk in place 0629 fb92 85 01 BITA #$1 0630 fb94 27 03 BEQ RDBLK1 ;yes, jump 0631 fb96 7e fc 60 JMP MISMED ;end with error 0632 RDBLK1: 0633 fb99 bd fd de JSR SELDRV ;turn on drive 0634 fb9c 86 05 LDAA #$5 ;set retry count to 5 0635 fb9e 97 aa STAA RETRY 0636 RDBLK2: 0637 fba0 cc 6c 00 LDD #RDMA0 ;DMA read to 1st half of memory 0638 fba3 dd a2 STD DMADDR 0639 fba5 96 a5 LDAA REQTRK ;seek to track 0640 fba7 bd fc e1 JSR SKTRK 0641 fbaa 26 28 BNE RDERR ;if seek error 0642 fbac 96 a6 LDAA REQSEC ;get logical sector 0643 fbae bd fe 1f JSR SECTRN ;translate to physical sector 0644 fbb1 bd fd 3b JSR RDSEC ;read it 0645 fbb4 4d TSTA ;test error code 0646 fbb5 26 1d BNE RDERR ;jump if error 0647 fbb7 cc 6e 00 LDD #RDMA1 ;DMA read to 2nd half of memory 0648 fbba dd a2 STD DMADDR 0649 fbbc 96 a6 LDAA REQSEC ;get logical sector 0650 fbbe 4c INCA ;increase by 1 0651 fbbf 81 0a CMPA #$0A ;past last sector on track 0652 fbc1 25 08 BCS RDBLK3 ;no, jump 0653 fbc3 96 a5 LDAA REQTRK ;get requested track 0654 fbc5 4c INCA ;increment to next track 0655 fbc6 bd fc e1 JSR SKTRK ;seek to it 0656 fbc9 86 01 LDAA #$1 ;must want first logical sector 0657 RDBLK3: 0658 fbcb bd fe 1f JSR SECTRN ;translate logical to physical 0659 fbce bd fd 3b JSR RDSEC ;read sector 0660 fbd1 4d TSTA ;test for error 0661 fbd2 27 1e BEQ OKRD ;everything is OK 0662 RDERR: 0663 fbd4 d6 aa LDAB RETRY ;get retries 0664 fbd6 5a DECB ;any left 0665 fbd7 d7 aa STAB RETRY ;save them 0666 fbd9 26 12 BNE RDRETRY ;do retry 0667 fbdb 4a DECA ;look at error 0668 fbdc 27 09 BEQ RDMBLK ;if 0, missing block 0669 fbde 4a DECA 0670 fbdf 27 06 BEQ RDMBLK ;still missing block 0671 fbe1 4a DECA 0672 fbe2 27 06 BEQ RDCRC ;CRC error 0673 fbe4 7e fc 60 JMP MISMED ;only thing left 0674 RDMBLK: 0675 fbe7 7e fc 74 JMP MISBLK ;end up with missing block error code 0676 RDCRC: 0677 fbea 7e fc 70 JMP CRC ;end up with crc error code 0678 RDRETRY: 0679 fbed bd fc bd JSR HOMDSK ;home the disk 0680 fbf0 20 ae BRA RDBLK2 ;do retry 0681 OKRD: 0682 fbf2 dc 80 LDD CURMSG ;transfer current message to last message 0683 fbf4 dd 85 STD LSTMSG 0684 fbf6 dc 82 LDD CURMSG+2 0685 fbf8 dd 87 STD LSTMSG+2 0686 fbfa 96 84 LDAA CURMSG+4 0687 fbfc 97 89 STAA LSTMSG+4 0688 fbfe 20 5d BRA OKRDWR ;finish up, no error 0689 WRTBLK: 0690 fc00 96 02 LDAA P1DATA ;is disk present 0691 fc02 85 01 BITA #$1 0692 fc04 26 5a BNE MISMED ;no, exit with error 0693 fc06 86 ff LDAA #$0FF ;force new read 0694 fc08 97 89 STAA LSTMSG+4 0695 fc0a bd fd de JSR SELDRV ;select the drive 0696 fc0d 86 05 LDAA #$5 ;set retries 0697 fc0f 97 aa STAA RETRY 0698 WRTBK1: 0699 fc11 cc 7c 00 LDD #WDMA0 ;DMA write from 1st half of memory 0700 fc14 dd a2 STD DMADDR 0701 fc16 96 a5 LDAA REQTRK 0702 fc18 bd fc e1 JSR SKTRK ;seek to requested track 0703 fc1b 26 28 BNE WRTBK3 ;jump if error 0704 fc1d 96 a6 LDAA REQSEC ;get requested sector 0705 fc1f bd fe 1f JSR SECTRN ;logical to physical translation 0706 fc22 bd fd 90 JSR WRTSEC ;write the sector 0707 fc25 4d TSTA ;test for error 0708 fc26 26 1d BNE WRTBK3 ;jump if error 0709 fc28 cc 7e 00 LDD #WDMA1 ;DMA write from 2nd half of memory 0710 fc2b dd a2 STD DMADDR 0711 fc2d 96 a6 LDAA REQSEC ;get requested sector 0712 fc2f 4c INCA ;go for next 0713 fc30 81 0a CMPA #$0A ;past end of track? 0714 fc32 25 08 BCS WRTBK2 ;jump if not 0715 fc34 96 a5 LDAA REQTRK ;seek to next track 0716 fc36 4c INCA 0717 fc37 bd fc e1 JSR SKTRK 0718 fc3a 86 01 LDAA #$1 ;get first sector 0719 WRTBK2: 0720 fc3c bd fe 1f JSR SECTRN ;logical to physical translation 0721 fc3f bd fd 90 JSR WRTSEC ;write sector 0722 fc42 4d TSTA ;test for error 0723 fc43 27 18 BEQ OKRDWR ;none, exit 0724 WRTBK3: 0725 fc45 d6 aa LDAB RETRY ;get retry count 0726 fc47 5a DECB ;any left? 0727 fc48 d7 aa STAB RETRY ;save retries 0728 fc4a 26 0c BNE WRTBK4 ;do retry 0729 fc4c 81 04 CMPA #$4 ;look at error code 0730 fc4e 27 10 BEQ MISMED ;must be missing media 0731 fc50 81 03 CMPA #$3 0732 fc52 26 20 BNE MISBLK ;must be missing block 0733 fc54 86 05 LDAA #$5 ;must be write-protected 0734 fc56 20 1e BRA DSKDN 0735 WRTBK4: 0736 fc58 bd fc bd JSR HOMDSK ;home disk 0737 fc5b 20 b4 BRA WRTBK1 ;go back for retry 0738 OKRDWR: 0739 fc5d 4f CLRA ;no error so clear A 0740 fc5e 20 16 BRA DSKDN 0741 MISMED: 0742 fc60 dc 80 LDD CURMSG ;transfer current message to last message 0743 fc62 dd 85 STD LSTMSG 0744 fc64 dc 82 LDD CURMSG+2 0745 fc66 dd 87 STD LSTMSG+2 0746 fc68 96 84 LDAA CURMSG+4 0747 fc6a 97 89 STAA LSTMSG+4 0748 fc6c 86 03 LDAA #$3 ;status = missing media 0749 fc6e 20 06 BRA DSKDN 0750 CRC: 0751 fc70 86 01 LDAA #$1 ;status = CRC error 0752 fc72 20 02 BRA DSKDN 0753 MISBLK: 0754 fc74 86 02 LDAA #$2 ;status = missing block error 0755 DSKDN: 0756 fc76 97 94 STAA PSTAT 0757 fc78 20 02 BRA DSKDN1 0758 ; 0759 fc7a 97 95 STAA SSTAT ;unused code for secondary device 0760 DSKDN1: 0761 fc7c 7f 00 9e CLR DATREQ 0762 fc7f 86 1b LDAA #$1B ;enable Tx, Rx, Wakeup 0763 fc81 97 11 STAA SCICSR 0764 DSKRES: 0765 fc83 bd fe 01 JSR RCOUNT 0766 fc86 86 1b LDAA #$1B ;enable Tx, Rx, Wakeup 0767 fc88 97 11 STAA SCICSR 0768 fc8a 4f CLRA 0769 fc8b 97 99 STAA CMDSTG ;reset command stage 0770 fc8d 0e CLI ;enable interrupts 0771 fc8e 7e fa ab JMP MAIN ;wait loop 0772 CLCTRK: 0773 fc91 37 PSHB ;save accumulators 0774 fc92 36 PSHA 0775 fc93 86 70 LDAA #$70 0776 fc95 97 02 STAA P1DATA 0777 fc97 d6 80 LDAB CURMSG ;get requested block in A & B 0778 fc99 96 81 LDAA CURMSG+1 0779 fc9b 05 LSLD ;multiply by 2 to go from 1K to 512 byte blocks 0780 fc9c 7f 00 a5 CLR REQTRK ;initialize REQTRK to -1 0781 fc9f 7a 00 a5 DEC REQTRK 0782 CLCTR1: 0783 fca2 83 00 08 SUBD #$8 ;divide sector requested by 8 0784 fca5 7c 00 a5 INC REQTRK ;keeping count in REQTRK 0785 fca8 24 f8 BCC CLCTR1 ;until overflow 0786 fcaa c3 00 09 ADDD #$9 ;add back overflow + 1 (sectors start at 1 not 0) 0787 fcad 96 a5 LDAA REQTRK ;check if requested track > 80 0788 fcaf 81 50 CMPA #$50 0789 fcb1 24 03 BCC CLCTR2 ;yes, skip next 0790 fcb3 d7 a6 STAB REQSEC ;save calculated sector 0791 fcb5 0d SEC ;set carry 0792 CLCTR2: 0793 fcb6 07 TPA ;transfer condition code register to A 0794 fcb7 88 01 EORA #$1 ;reverse what was the carry 0795 fcb9 06 TAP ;transfer A to condition code register 0796 fcba 32 PULA ;restore A & B 0797 fcbb 33 PULB 0798 fcbc 39 RTS 0799 HOMDSK: 0800 fcbd 96 02 LDAA P1DATA ;check if disk in place 0801 fcbf 85 01 BITA #$1 0802 fcc1 26 15 BNE HOMDK2 ;if not finish up 0803 fcc3 ce fc d8 LDX #HOMDK2 ;set up interrupt handler 0804 fcc6 df a0 STX INTHAN 0805 fcc8 ce 18 00 LDX #FDCCMD ;prepare to write to FDC command register 0806 fccb 86 04 LDAA #$4 ;restore command with verify and 6ms step rate 0807 fccd a7 00 STAA $0,X ;do it 0808 fccf 86 01 LDAA #$1 0809 HOMDK1: 0810 fcd1 95 02 BITA P1DATA ;keep testing for disk in place 0811 fcd3 27 fc BEQ HOMDK1 0812 fcd5 bd fe 13 JSR FORINT ;oops, disk gone so force interrupt 0813 HOMDK2: 0814 fcd8 ce 38 00 LDX #FDCTRK ;prepare to write to FDC track register 0815 fcdb 4f CLRA 0816 fcdc a7 00 STAA $0,X ;put a 0 there 0817 fcde 97 a8 STAA CURTRK ;and in current track 0818 fce0 39 RTS 0819 SKTRK: 0820 fce1 d6 02 LDAB P1DATA ;is disk in plce 0821 fce3 c5 01 BITB #$1 0822 fce5 26 51 BNE DSKERR ;no, branch to error 0823 fce7 81 50 CMPA #$50 ;is track greater than 80 0824 fce9 24 4d BCC DSKERR ;yes, branch to error 0825 fceb 81 28 CMPA #$28 ;is it less than 40 0826 fced 25 0a BCS SKTRK1 ;yes, skip next 0827 fcef 80 28 SUBA #$28 ;subtract 40 0828 ;comment out next 3 lines if using 2797 side select line 0829 fcf1 d6 02 LDAB P1DATA ;select side 1 0830 fcf3 c4 ef ANDB #$0EF 0831 fcf5 d7 02 STAB P1DATA 0832 ; LDAB #$2 ;for read/write sector ******* 0833 ; STAB SIDE ;******** 0834 fcf7 20 06 BRA SKTRK2 ;skip next 0835 SKTRK1: 0836 ;comment out next 3 lines if using 2797 side select line 0837 fcf9 d6 02 LDAB P1DATA ;select side 0 0838 fcfb ca 10 ORAB #$10 0839 fcfd d7 02 STAB P1DATA 0840 ; CLR SIDE ;******* 0841 SKTRK2: 0842 fcff ce fd 1d LDX #SKTRK4 ;set up interrupt handler 0843 fd02 df a0 STX INTHAN 0844 fd04 ce 78 00 LDX #FDCDAT ;prepare to write to FDC data register 0845 fd07 a7 00 STAA $0,X ;put track there 0846 fd09 97 a8 STAA CURTRK ;save in current track 0847 fd0b ce 18 00 LDX #FDCCMD ;prepare to write to FDC command register 0848 fd0e c6 14 LDAB #$14 ;seek commmand, with verify and 6ms step rate 0849 fd10 e7 00 STAB $0,X ;do it 0850 fd12 86 01 LDAA #$1 0851 SKTRK3: 0852 fd14 95 02 BITA P1DATA ;keep testing disk in place 0853 fd16 27 fc BEQ SKTRK3 ;until FDC interrupts out 0854 fd18 bd fe 13 JSR FORINT ;oops, disk out so force interrupt 0855 fd1b 20 1b BRA DSKERR ;and send error 0856 SKTRK4: 0857 fd1d 96 a8 LDAA CURTRK ;get current track 0858 fd1f ce 38 00 LDX #FDCTRK ;get ready to write to FDC track register 0859 fd22 a7 00 STAA $0,X ;put track in register 0860 fd24 81 12 CMPA #$12 ;is it track 12 or less 0861 fd26 24 08 BCC SKTRK5 ;no, skip next 0862 fd28 96 02 LDAA P1DATA ;disable write precompensation 0863 fd2a 84 fd ANDA #$0FD 0864 fd2c 97 02 STAA P1DATA 0865 fd2e 20 06 BRA SKTRK6 ;skip next 0866 SKTRK5: 0867 fd30 96 02 LDAA P1DATA ;enable write precompensation 0868 fd32 8a 02 ORAA #$2 0869 fd34 97 02 STAA P1DATA 0870 SKTRK6: 0871 fd36 4f CLRA ;finish up with no error 0872 fd37 39 RTS 0873 DSKERR: 0874 fd38 86 01 LDAA #$1 0875 fd3a 39 RTS 0876 RDSEC: 0877 fd3b 97 a7 STAA CURSEC ;save sector 0878 fd3d 81 0a CMPA #$0A ;past end of track? 0879 fd3f 24 2d BCC RDSEC3 ;end with error 0880 fd41 86 02 LDAA #$2 ;set retries 0881 fd43 97 a9 STAA SECCNT 0882 RDSEC1: 0883 fd45 ce 58 00 LDX #FDCSEC ;get ready to set FDC sector register 0884 fd48 96 a7 LDAA CURSEC ;with sector 0885 fd4a a7 00 STAA $0,X ;do it 0886 fd4c ce fd 72 LDX #RDSEC4 ;set up interrupt handler 0887 fd4f df a0 STX INTHAN 0888 fd51 ce 18 00 LDX #FDCCMD ;get ready to set FDC command register 0889 fd54 86 84 LDAA #$84 ;read sector command with no side compare ***** 0890 ;and 30ms delay 0891 ; LDAA #$8C ;read sector command ********* 0892 ; ORAA SIDE ;set side select ********* 0893 fd56 a7 00 STAA $0,X ;do it 0894 fd58 de a2 LDX DMADDR point to memory to save data 0895 RDSEC2: 0896 fd5a d6 02 LDAB P1DATA ;check if disk in place and FDC DRQ 0897 fd5c c5 05 BITB #$5 0898 fd5e 27 fa BEQ RDSEC2 ;loop until check positive 0899 fd60 a6 00 LDAA $0,X ;get data 0900 fd62 08 INX ;next memory address 0901 fd63 c5 01 BITB #$1 ;disk in place? 0902 fd65 27 f3 BEQ RDSEC2 ;yes go for more data 0903 fd67 bd fe 13 JSR FORINT ;force interrupt 0904 fd6a 86 04 LDAA #$4 ;missing media error 0905 fd6c 20 21 BRA RDSEC7 ;exit 0906 RDSEC3: 0907 fd6e 86 01 LDAA #$1 ;missing block error 0908 fd70 20 1d BRA RDSEC7 ;exit 0909 RDSEC4: 0910 fd72 d6 a4 LDAB STFDC ;get floppy disk status 0911 fd74 86 03 LDAA #$3 ;assume error 3, CRC 0912 fd76 c5 0c BITB #$0C ;test status 0913 fd78 27 07 BEQ RDSEC5 ;no, its not 0914 fd7a 7a 00 a9 DEC SECCNT ;decrement retries 0915 fd7d 26 c6 BNE RDSEC1 ;do another 0916 fd7f 20 0e BRA RDSEC7 ;else exit 0917 RDSEC5: 0918 fd81 86 02 LDAA #$2 ;assume error 2 0919 fd83 c5 10 BITB #$10 ;test for sector not found 0920 fd85 27 07 BEQ RDSEC6 ;if not, no error so exit 0921 fd87 7a 00 a9 DEC SECCNT ;decrement retries 0922 fd8a 26 b9 BNE RDSEC1 ;do another 0923 fd8c 20 01 BRA RDSEC7 ;else exit 0924 RDSEC6: 0925 fd8e 4f CLRA ;no error 0926 RDSEC7: 0927 fd8f 39 RTS ;exit 0928 WRTSEC: 0929 fd90 97 a7 STAA CURSEC ;save in current sector 0930 fd92 81 0a CMPA #$0A ;past end of track 0931 fd94 24 2d BCC WRTSC3 ;exit missing block 0932 fd96 86 02 LDAA #$2 ;set retries 0933 fd98 97 a9 STAA SECCNT 0934 WRTSC1: 0935 fd9a 96 a7 LDAA CURSEC ;get current sector 0936 fd9c ce 58 00 LDX #FDCSEC ;prepare to write to FDC sector register 0937 fd9f a7 00 STAA $0,X ;do it 0938 fda1 ce fd c7 LDX #WRTSC4 ;set up interrupt handler 0939 fda4 df a0 STX INTHAN 0940 fda6 86 a4 LDAA #$0A4 ;FDC write command ****** 0941 ; LDAA #$0AC ;FDC write command ********* 0942 ; ORAA SIDE ;set side select ********* 0943 fda8 ce 18 00 LDX #FDCCMD ;prepare to write to FDC command register 0944 fdab a7 00 STAA $0,X ;do it 0945 fdad de a2 LDX DMADDR 0946 WRTSC2: 0947 fdaf d6 02 LDAB P1DATA ;check if disk in place and FDC DRQ 0948 fdb1 c5 05 BITB #$5 0949 fdb3 27 fa BEQ WRTSC2 ;loop until check positive 0950 fdb5 a6 00 LDAA $0,X ;get data 0951 fdb7 08 INX ;next memory address 0952 fdb8 c5 01 BITB #$1 ;disk still in place 0953 fdba 27 f3 BEQ WRTSC2 ;yes go for more data 0954 fdbc bd fe 13 JSR FORINT ;force interrupt 0955 fdbf 86 04 LDAA #$4 ;missing media error 0956 fdc1 20 1a BRA WRTSC6 ;exit 0957 WRTSC3: 0958 fdc3 86 01 LDAA #$1 ;missing block error 0959 fdc5 20 16 BRA WRTSC6 ;exit 0960 WRTSC4: 0961 fdc7 d6 a4 LDAB STFDC ;get floppy disk status 0962 fdc9 86 02 LDAA #$2 ;assume missing block error 0963 fdcb c5 14 BITB #$14 ;test status 0964 fdcd 27 07 BEQ WRTSC5 ;not CRC 0965 fdcf 7a 00 a9 DEC SECCNT ;decrement retry count 0966 fdd2 26 c6 BNE WRTSC1 ;do another 0967 fdd4 20 07 BRA WRTSC6 ;else exit 0968 WRTSC5: 0969 fdd6 86 03 LDAA #$3 ;assume CRC error 0970 fdd8 c5 40 BITB #$40 ;test status 0971 fdda 26 01 BNE WRTSC6 ;got CRC 0972 fddc 4f CLRA ;everything OK 0973 WRTSC6: 0974 fddd 39 RTS ;exit 0975 SELDRV: 0976 fdde 36 PSHA ;save A & IX 0977 fddf 3c PSHX 0978 fde0 96 02 LDAA P1DATA ;test if drive is selected 0979 fde2 85 20 BITA #$20 0980 fde4 26 0f BNE SELDR3 ;yes, finish up 0981 fde6 8a 70 ORAA #$70 ;turn motor on, select drive and side 0 0982 fde8 97 02 STAA P1DATA 0983 fdea 86 02 LDAA #$2 ;counter for outer wait loop 0984 SELDR1: 0985 fdec ce 9c 40 LDX #$9C40 ;counter for inner wait loop 0986 SELDR2: 0987 fdef 09 DEX 0988 fdf0 26 fd BNE SELDR2 ;do inner loop 0989 fdf2 4a DECA 0990 fdf3 26 f7 BNE SELDR1 ;do outer loop 0991 SELDR3: 0992 fdf5 38 PULX ;restore IX and A 0993 fdf6 32 PULA 0994 fdf7 39 RTS 0995 ; 0996 fdf8 36 PSHA ;unused code 0997 fdf9 96 02 LDAA P1DATA 0998 fdfb 84 9f ANDA #$9F 0999 fdfd 97 02 STAA P1DATA 1000 fdff 32 PULA 1001 fe00 39 RTS 1002 ; 1003 RCOUNT: 1004 fe01 96 08 LDAA TCSR ;set output compare to counter + 3E80H 1005 fe03 dc 09 LDD COUNTER 1006 fe05 c3 3e 80 ADDD #$3E80 1007 fe08 dd 0b STD OUTCMP 1008 fe0a 86 fa LDAA #$0FA ;put 0FAH in MOTON 1009 fe0c 97 ac STAA MOTON 1010 fe0e 39 RTS 1011 ; 1012 fe0f 86 03 LDAA #$3 ;unused code 1013 fe11 97 94 STAA PSTAT 1014 ; 1015 FORINT: 1016 fe13 ce 18 00 LDX #FDCCMD ;get ready to write to FDC command register 1017 fe16 86 d0 LDAA #$0D0 ;force interrupt cmd - terminate with 1018 ;no interrupt 1019 fe18 a7 00 STAA $0,X ;do it 1020 fe1a 86 01 LDAA #$1 ;set drive not used 1021 fe1c 97 ab STAA DRVUSE 1022 fe1e 39 RTS 1023 ; 1024 SECTRN: 1025 fe1f 3c PSHX ;save IX & B 1026 fe20 37 PSHB 1027 fe21 16 TAB ;transfer A to B 1028 fe22 5a DECB ;dec B 1029 fe23 ce fe 2c LDX #SKEW ;point to skew table 1030 fe26 3a ABX ;add offset 1031 fe27 a6 00 LDAA $0,X ;get physical sector 1032 fe29 33 PULB ;restore IX & B 1033 fe2a 38 PULX 1034 fe2b 39 RTS 1035 SKEW: 1036 fe2c 01 06 03 08 05 02 DB 1,6,3,8,5,2,7,4 07 04 1037 FDCINT: 1038 fe34 ce 08 00 LDX #FDCSTAT ;read FDC status register 1039 fe37 a6 00 LDAA $0,X 1040 fe39 30 TSX ;transfer stack pointer to X 1041 fe3a c6 05 LDAB #$5 ;increase by 5 1042 fe3c 3a ABX 1043 fe3d dc a0 LDD INTHAN ;get interrupt handler in DA 1044 fe3f a7 00 STAA $0,X ;put in stack 1045 fe41 08 INX 1046 fe42 e7 00 STAB $0,X 1047 fe44 ce 08 00 LDX #FDCSTAT ;prepare to read FDC status register 1048 FDCIN2: 1049 fe47 21 fe BRN FDCIN2 ;delay 1050 fe49 a6 00 LDAA $0,X ;read status 1051 fe4b 97 a4 STAA STFDC 1052 fe4d 3b RTI 1053 fe4e 3b RTI ;unused 1054 FORMAT: 1055 fe4f 7f 00 ec CLR SIDE ;clear side 2 flag 1056 fe52 96 02 LDAA P1DATA ;is disk in place? 1057 fe54 85 01 BITA #$1 1058 fe56 27 03 BEQ FMT1 ;yes, go on formatting 1059 fe58 7e ff d5 JMP FMTEXIT ;no, exit with error 1060 FMT1: 1061 fe5b bd fc bd JSR HOMDSK ;home disk ****** useless should comment out 1062 fe5e 86 27 LDAA #$27 ;set track to format 1063 fe60 97 e9 STAA FMTTRK 1064 FMT2: 1065 fe62 ce fe 77 LDX #FMT4 ;set up interrupt handler 1066 fe65 df a0 STX INTHAN 1067 fe67 ce 78 00 LDX #FDCDAT ;prepare to write to FDC data register 1068 fe6a 96 e9 LDAA FMTTRK ;get track 1069 fe6c a7 00 STAA $0,X ;put in data register 1070 fe6e ce 18 00 LDX #FDCCMD ;prepare to write to FDC command register 1071 fe71 86 10 LDAA #$10 ;seek command, no verify, 6ms step 1072 fe73 a7 00 STAA $0,X ;issue command 1073 FMT3: 1074 fe75 20 fe BRA FMT3 ;wait for seek to end 1075 FMT4: 1076 fe77 86 0a LDAA #$0A ;set format retries to 10 1077 fe79 97 eb STAA FMTRTRY 1078 FMT5: 1079 fe7b 96 02 LDAA P1DATA ;turn motor on, and select drive 1 1080 fe7d 84 70 ANDA #$70 1081 fe7f 8a 60 ORAA #$60 1082 fe81 97 02 STAA P1DATA 1083 fe83 86 01 LDAA #$1 ;set format sector to 1 1084 fe85 97 ea STAA FMTSEC 1085 fe87 ce ff 96 LDX #FMT37 ;set up pointer to interrupt handler 1086 fe8a df a0 STX INTHAN 1087 fe8c 96 e9 LDAA FMTTRK ;get current track 1088 fe8e 81 12 CMPA #$12 ;is it less than 12 1089 fe90 24 0a BCC FMT6 ;no, jump 1090 fe92 96 02 LDAA P1DATA ;enable write precompensation 1091 fe94 84 fd ANDA #$0FD 1092 fe96 97 02 STAA P1DATA 1093 fe98 86 f0 LDAA #$0F0 ;FDC write track command in A 1094 fe9a 20 08 BRA FMT7 1095 FMT6: 1096 ;comment out next 3 lines if using 2797 side select line 1097 fe9c 96 02 LDAA P1DATA ;disable write precompensation 1098 fe9e 8a 02 ORAA #$2 1099 fea0 97 02 STAA P1DATA 1100 fea2 86 f0 LDAA #$0F0 ;FDC write track command in A 1101 ; ORAA SIDE ;set side select ******** 1102 FMT7: 1103 fea4 ce 18 00 LDX #FDCCMD ;prepare to write to FDC command register 1104 fea7 a7 00 STAA $0,X ;do it 1105 fea9 ce 78 00 LDX #FDCDAT ;prepare to write to FDC data register 1106 feac c6 64 LDAB #$64 ;write 64H/100D bytes of data 1107 FMT8: 1108 feae 86 04 LDAA #$4 ;prepare to test DRQ 1109 FMT9: 1110 feb0 95 02 BITA P1DATA ;test it 1111 feb2 27 fc BEQ FMT9 ;loop til set 1112 feb4 86 4e LDAA #$4E ;write 4EH 1113 feb6 a7 00 STAA $0,X 1114 feb8 5a DECB ;decrement count 1115 feb9 26 f3 BNE FMT8 ;loop till count gone 1116 FMT10: 1117 febb c6 0c LDAB #$0C ;now writing 0CH/12D bytes 1118 FMT11: 1119 febd 86 04 LDAA #$4 ;prepare to test DRQ 1120 FMT12: 1121 febf 95 02 BITA P1DATA ;test it 1122 fec1 27 fc BEQ FMT12 ;loop till set 1123 fec3 4f CLRA ;write 0 1124 fec4 a7 00 STAA $0,X ;do it 1125 fec6 5a DECB ;decrement count 1126 fec7 26 f4 BNE FMT11 ;loop till exhausted 1127 fec9 c6 03 LDAB #$3 ;now write 3 bytes 1128 FMT13: 1129 fecb 86 04 LDAA #$4 ;prepare to test DRQ 1130 FMT14: 1131 fecd 95 02 BITA P1DATA ;test it 1132 fecf 27 fc BEQ FMT14 ;loop till set 1133 fed1 86 f5 LDAA #$0F5 ;write 0F5H (3 bytes of A1) 1134 fed3 a7 00 STAA $0,X ;do it 1135 fed5 5a DECB ;decrement count 1136 fed6 26 f3 BNE FMT13 ;loop till exhausted 1137 fed8 86 04 LDAA #$4 ;prepare to test DRQ 1138 FMT15: 1139 feda 95 02 BITA P1DATA ;test it 1140 fedc 27 fc BEQ FMT15 ;loop till set 1141 fede 86 fe LDAA #$0FE ;write 0FEH (index mark) 1142 fee0 a7 00 STAA $0,X ;do it 1143 fee2 86 04 LDAA #$4 ;prepare to test DRQ 1144 FMT16: 1145 fee4 95 02 BITA P1DATA ;test it 1146 fee6 27 fc BEQ FMT16 ;loop till set 1147 fee8 96 e9 LDAA FMTTRK ;get track number 1148 feea a7 00 STAA $0,X ;wwrite to FDC 1149 feec 86 04 LDAA #$4 ;prepare to test DRQ 1150 FMT17: 1151 feee 95 02 BITA P1DATA ;test it 1152 fef0 27 fc BEQ FMT17 ;loop till set 1153 fef2 96 ec LDAA SIDE ;get side 1154 ; LSRA ;convert to 0&1 instead of 0&2 ****** 1155 fef4 a7 00 STAA $0,X ;write it 1156 fef6 86 04 LDAA #$4 ;prepare to test DRQ 1157 FMT18: 1158 fef8 95 02 BITA P1DATA ;test it 1159 fefa 27 fc BEQ FMT18 ;loop till set 1160 fefc 96 ea LDAA FMTSEC ;get sector number 1161 fefe a7 00 STAA $0,X ;write it 1162 ff00 4c INCA ;increment sector number 1163 ff01 97 ea STAA FMTSEC ;save it 1164 ff03 86 04 LDAA #$4 ;prepare to test DRQ 1165 FMT19: 1166 ff05 95 02 BITA P1DATA ;test it 1167 ff07 27 fc BEQ FMT19 ;wait till set 1168 ff09 86 02 LDAA #$2 ;write sector length byte (2 = 512 bytes) 1169 ff0b a7 00 STAA $0,X ;write it 1170 ff0d 86 04 LDAA #$4 ;prepare to test DRQ 1171 FMT20: 1172 ff0f 95 02 BITA P1DATA ;test it 1173 ff11 27 fc BEQ FMT20 ;loop till set 1174 ff13 86 f7 LDAA #$0F7 ;write 0F7H (writes CRC) 1175 ff15 a7 00 STAA $0,X ;write it 1176 ff17 c6 16 LDAB #$16 ;load count with 16H/22D 1177 FMT21: 1178 ff19 86 04 LDAA #$4 ;prepare to test DRQ 1179 FMT22: 1180 ff1b 95 02 BITA P1DATA ;test it 1181 ff1d 27 fc BEQ FMT22 ;loop till set 1182 ff1f 86 4e LDAA #$4E ;write 4EH 1183 ff21 a7 00 STAA $0,X ;write it 1184 ff23 5a DECB ;decrement count 1185 ff24 26 f3 BNE FMT21 ;loop till exhausted 1186 ff26 c6 0c LDAB #$0C ;load count with 0CH/12D 1187 FMT23: 1188 ff28 86 04 LDAA #$4 ;get ready to test DRQ 1189 FMT24: 1190 ff2a 95 02 BITA P1DATA ;test it 1191 ff2c 27 fc BEQ FMT24 ;loop till done 1192 ff2e 4f CLRA ;write 0 1193 ff2f a7 00 STAA $0,X ;write it 1194 ff31 5a DECB ;decrement count 1195 ff32 26 f4 BNE FMT23 ;loop till exhausted 1196 ff34 c6 03 LDAB #$3 ;count = 3 1197 FMT25: 1198 ff36 86 04 LDAA #$4 ;prepare to test DRQ 1199 FMT26: 1200 ff38 95 02 BITA P1DATA ;test it 1201 ff3a 27 fc BEQ FMT26 ;loop till set 1202 ff3c 86 f5 LDAA #$0F5 ;write 0F5H (3 bytes of A1) 1203 ff3e a7 00 STAA $0,X ;write it 1204 ff40 5a DECB ;decrement count 1205 ff41 26 f3 BNE FMT25 ;loop till exhausted 1206 ff43 86 04 LDAA #$4 ;prepare to test DRQ 1207 FMT27: 1208 ff45 95 02 BITA P1DATA ;test it 1209 ff47 27 fc BEQ FMT27 ;loop till set 1210 ff49 86 fb LDAA #$0FB ;write 0FBH (address mark) 1211 ff4b a7 00 STAA $0,X ;write it 1212 ff4d 5f CLRB ;clear B (count = 256) 1213 FMT28: 1214 ff4e 86 04 LDAA #$4 ;prepare to test DRQ 1215 FMT29: 1216 ff50 95 02 BITA P1DATA ;test it 1217 ff52 27 fc BEQ FMT29 ;loop till set 1218 ff54 86 e5 LDAA #$0E5 ;write 0E5H 1219 ff56 a7 00 STAA $0,X ;write it 1220 ff58 5a DECB ;decrement count 1221 ff59 26 f3 BNE FMT28 ;loop till exhausted 1222 FMT30: 1223 ff5b 86 04 LDAA #$4 ;prepare to test DRQ 1224 FMT31: 1225 ff5d 95 02 BITA P1DATA ;test it 1226 ff5f 27 fc BEQ FMT31 ;loop till set 1227 ff61 86 e5 LDAA #$0E5 ;writing 0E5H 1228 ff63 a7 00 STAA $0,X ;write it 1229 ff65 5a DECB ;decrement count 1230 ff66 26 f3 BNE FMT30 ;loop till exhausted 1231 ff68 86 04 LDAA #$4 ;prepare to test DRQ 1232 FMT32: 1233 ff6a 95 02 BITA P1DATA ;test it 1234 ff6c 27 fc BEQ FMT32 ;loop till set 1235 ff6e 86 f7 LDAA #$0F7 ;writing 0F7H (CRC) 1236 ff70 a7 00 STAA $0,X ;write it 1237 ff72 c6 64 LDAB #$64 ;count = 64H/100D 1238 FMT33: 1239 ff74 86 04 LDAA #$4 ;prepare to test DRQ 1240 FMT34: 1241 ff76 95 02 BITA P1DATA ;test it 1242 ff78 27 fc BEQ FMT34 ;loop till set 1243 ff7a 86 4e LDAA #$4E ;writing 4EH 1244 ff7c a7 00 STAA $0,X ;write it 1245 ff7e 5a DECB ;decrement count 1246 ff7f 26 f3 BNE FMT33 ;loop till exhausted 1247 ff81 96 ea LDAA FMTSEC ;get next sector number to format 1248 ff83 81 0a CMPA #$0A ;is it 10 yet (always format 9 sectors) 1249 ff85 27 03 BEQ FMT35 ;yes, jump 1250 ff87 7e fe bb JMP FMT10 ;no, go back and write another sector 1251 FMT35: 1252 ff8a c6 4e LDAB #$4E ;get ready to fill track with 4EH 1253 FMT36: 1254 ff8c 96 02 LDAA P1DATA ;test DRQ 1255 ff8e 85 04 BITA #$4 ;is it set 1256 ff90 27 fa BEQ FMT36 ;no, loop till set 1257 ff92 e7 00 STAB $0,X ;write byte 1258 ff94 20 f6 BRA FMT36 ;loop till FDC interrupts out 1259 FMT37: 1260 ;format continues here once one track is formatted 1261 ff96 ce 08 00 LDX #FDCSTAT ;read FDC status register 1262 ff99 e6 00 LDAB $0,X 1263 ff9b c5 01 BITB #$1 ;test busy 1264 ff9d 26 f7 BNE FMT37 ;wait till not busy 1265 ff9f 96 a4 LDAA STFDC ;get status after command completed 1266 ffa1 85 04 BITA #$4 ;test for lost data 1267 ffa3 27 08 BEQ FMT38 ;jump if none 1268 ffa5 7a 00 eb DEC FMTRTRY ;decrement retries 1269 ffa8 27 03 BEQ FMT38 ;loop if exhausted 1270 ffaa 7e fe 7b JMP FMT5 ;re-format track 1271 FMT38: 1272 ; LDDA BLKRD ;read first byte of data block 1273 ; CMPA #$1 ;is it 1 1274 ; BEQ FMT39 ;if it is, do not format side 1 1275 ffad 96 ec LDAA SIDE ;get the side 1276 ffaf 26 0b BNE FMT39 ;jump if we just did side 1 1277 ffb1 7c 00 ec INC SIDE ;increment side ******* 1278 ; LDAA #$2 ;******** 1279 ; STAA SIDE ;******** 1280 ;comment out next 3 lines if using 2797 side select line 1281 ffb4 96 02 LDAA P1DATA ;select side 1 1282 ffb6 84 ef ANDA #$0EF 1283 ffb8 97 02 STAA P1DATA 1284 ffba 20 0c BRA FMT40 ;skip next 1285 FMT39: 1286 ffbc 7f 00 ec CLR SIDE ;select side 0 1287 ;comment out next 3 lines if using 2797 side select line 1288 ffbf 96 02 LDAA P1DATA 1289 ffc1 8a 10 ORAA #$10 1290 ffc3 97 02 STAA P1DATA 1291 ;L160: 1292 ffc5 7a 00 e9 DEC FMTTRK ;decrement track to format 1293 FMT40: 1294 ffc8 96 e9 LDAA FMTTRK ;check if formatted all tracks 1295 ffca 81 ff CMPA #$0FF 1296 ffcc 27 03 BEQ FMT41 ;yes finish up 1297 ffce 7e fe 62 JMP FMT2 ;no, go back and format new track 1298 FMT41: 1299 ffd1 bd fc bd JSR HOMDSK ;home the disk (it already is) 1300 ffd4 39 RTS ;exit 1301 FMTEXIT: 1302 ffd5 86 10 LDAA #$10 ;turn motor and drive off 1303 ffd7 97 02 STAA P1DATA 1304 ffd9 39 RTS 1305 ; 1306 ffef ORG 0FFEFH 1307 ; 1308 RETI: 1309 ffef 3b RTI ;return from interrupt 1310 fff0 f8 01 DW SCIINT ;IRQ2/SCI (RDRF,ORFE,TDRE) 1311 fff2 ff ef DW RETI ;IRQ2/Timer overflow 1312 fff4 ff ef DW RETI ;IRQ2/Timer output compare 1313 fff6 ff ef DW RETI ;IRQ2/Timer input capture 1314 fff8 ff ef DW RETI ;IRQ1 interrupt (IRQ1 - IS3) 1315 fffa ff ef DW RETI ;software interrupt (SWI) 1316 fffc fe 34 DW FDCINT ;Non-maskable Interrupt 1317 fffe fa 67 DW RESET ;reset 1318 END Number of errors 0